﻿using System;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace VisualPureBasicIDE.CoreGUI
{
    public partial class UnhandledVpbideExceptionForm : Form
    {
        private Exception _exception;

        public UnhandledVpbideExceptionForm(Exception exception)
        {
            InitializeComponent();

            _exception = exception;

            // Replace the pattern $type with the exception type
            var regex = new Regex("{type}");
            labelTitle.Text = regex.Replace(labelTitle.Text, _exception.GetType().ToString());
        }

        private void buttonSendReport_Click(object sender, EventArgs e)
        {
            // Send the exception data via EMail
            Logger.SendException(_exception);
            _exception = null;
            Close();
        }

        private void buttonContinue_Click(object sender, EventArgs e)
        {
            // Just log the exception to the console
            Logger.LogException(_exception);
            Close();
        }
    }
}